﻿#region Header
// ------------------------ Licence / Copyright ------------------------
// 
// ScrumTable for Scrum Meeting Support
// Copyright © HSR - Hochschule für Technik Rapperswil
// All Rights Reserved
// 
// Author:
//  Michael Gfeller Silvan Gehrig Patrick Boos
// 
// ---------------------------------------------------------------------
#endregion

#region Usings

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using ScrumTable.Common;
using ScrumTable.Common.Collections;
using ScrumTable.Common.EventHandling;
using ScrumTable.DL.Data.Generic.Properties;

#endregion

namespace ScrumTable.DL.Data.Generic.Cache
{
    /// <summary>
    /// Represents a revision wrapper which is used to retrieve all revision
    /// updates.
    /// </summary>
    public class CacheWorkItemRevision : ICacheIdentity
    {
        #region Declarations
        //--------------------------------------------------------------------
        // Declarations
        //--------------------------------------------------------------------

        #endregion

        #region Properties
        //--------------------------------------------------------------------
        // Properties
        //--------------------------------------------------------------------

        /// <summary>
        /// Gets the tfs id of the element. Caution: This id is unique in
        /// the current storage only.
        /// </summary>
        public int Id { get; private set; }

        /// <summary>
        /// Returns true if the current element contains has an id assigned.
        /// </summary>
        public bool HasId { get { return (Id != CacheIdentity.DefaultId); } }

        /// <summary>
        /// Gets the global unqiue id of the tfs element.
        /// </summary>
        public string UniqueId { get; private set; }

        /// <summary>
        /// Gets the revision (server side versioning information) of the current element.
        /// </summary>
        public int Revision { get { return CacheIdentity.DefaultRevision; } }

        /// <summary>
        /// Gets the identity category (element type).
        /// </summary>
        public string Category { get { return CacheElementFactory.GetCategoryByType(GetType()); } }

        /// <summary>
        /// Returns the underlying history string.
        /// </summary>
        public string History
        {
            get;
            private set;
        }

        #endregion

        #region Constructors / Destructor
        //--------------------------------------------------------------------
        // Constructors / Destructor
        //--------------------------------------------------------------------

        /// <summary>
        /// Initializes a new instance of the <see cref="CacheWorkItemRevision"/> class.
        /// </summary>
        /// <param name="uniqueId">Specifies the unique id of the current revision.</param>
        /// <param name="id">Specifies the team foundation revision id.</param>
        /// <param name="name">Specfies the revision tagline.</param>
        /// <param name="history">Specfies the revision history data.</param>
        internal CacheWorkItemRevision(
            string uniqueId,
            int id,
            string name,
            string history = null)
        {
            PreCondition.AssertNotNullOrEmpty(uniqueId, "uniqueId");
            PreCondition.AssertNotNull(name, "name");

            Id = id;
            UniqueId = uniqueId;
            History = history ?? string.Empty;
        }

        #endregion

        #region Methods
        //--------------------------------------------------------------------
        // Methods
        //--------------------------------------------------------------------

        #endregion

        #region Events
        //--------------------------------------------------------------------
        // Events
        //--------------------------------------------------------------------

        #endregion
    }
}